/**
 * CEAport framework to create open APIs for communications enable applications.
 * https://ceaport.googlecode.com
 *
 * Copyright (c) 2008 by respective authors (see below).
 *
 * This program is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 2.1 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * Contributors:
 * Michael Weiss (michael.r.weiss@gmail.com)
 * 
 */
package org.ceaport.rest.server;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

/**
 * Conferences are identified by a host and room. Conferences contain users and messages.
 * 
 * @author michael.r.weiss
 *
 */
public class Conference {
	protected String host;
	protected String room;
	
	protected HashMap<String, User> users = new HashMap<String, User>();
	protected List<Message> messages = new ArrayList<Message>();
	
	public Conference(String host, String room) {
		this.host = host;
		this.room = room;
	}
	
	public String getHost() {
		return host;
	}
	
	public String getRoom() {
		return room;
	}
	
	public void addUser(String uid, User user) {
		users.put(uid, user);
	}
	
	public void removeUser(String uid) {
		users.remove(uid);
	}
	
	public Collection<String> getUsers() {
		return users.keySet();
	}
	
	public int getNumberOfUsers() {
		return users.size();
	}
	
	public User getUser(String uid) {
		return users.get(uid);
	}
	
	// public User findUserByName(String name)
	// public User findUserByPhone(String phone)
	
	public void addMessage(String user, String message) {
		messages.add(new Message(user, message));
	}
	
	public Message getMessage(int i) {
		return messages.get(i);
	}
	
	public int getNumberOfMessages() {
		return messages.size();
	}

}
